package com.shuma.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuma.auth.model.po.Orders;
import com.shuma.auth.model.to.ExchangeDataAndDateTo;
import com.shuma.auth.model.to.SaleAndCategoryTo;
import com.shuma.auth.model.to.SaleAndExchangeWayTo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lele
 */
@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {

    @Select("select sum(amount) from orders where finish_time > #{begin} and finish_time < #{end} and state = #{state}")
    Integer sumByMap(Map map);


    /**
     * desc SELECT SUM(amount) 总金额,Date(order_time) 日期
     * FROM orders
     * WHERE order_time<'2024-12-16'
     * AND order_time>'2024-06-05'
     * group BY Date(order_time)
     * ORDER BY DATE(order_time)
     * @return
     */
    List<ExchangeDataAndDateTo> sumByMap1(Map map);

    /**
     * SELECT SUM(amount) sale,product_categrory categoryName
     * FROM orders
     * where finish_time >'2024-1-1'
     * and finish_time < '2024-10-1'
     * and state = 4
     * group BY product_categrory
     * ORDER BY SUM(amount) desc
     * limit 20
     */
    List<SaleAndCategoryTo> saleAndCategory(Map map);

    /**
     * #兑换方式统计
     * SELECT SUM(amount) sale,price_type priceType
     * FROM orders
     * where finish_time >'2024-1-1'
     * and finish_time < '2024-10-1'
     * and state = 4
     * group BY price_type
     */

    List<SaleAndExchangeWayTo> saleAndExchangeWay(Map map);

}
